package com.example.myapplication.textview;

import android.graphics.Paint;
import android.graphics.Typeface;
import android.text.Spannable;
import android.text.Spanned;
import android.text.style.StyleSpan;
import android.util.Log;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.example.myapplication.R;

public class TextViewActitvity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_text_view_actitvity);

        TextView view = (TextView) findViewById(R.id.view_text);

        Log.d(TextViewActitvity.class.getName(), String.valueOf(view.getText().charAt(4)));

        Spannable spannable = (Spannable) view.getText();
        StyleSpan styleSpan = new StyleSpan(Typeface.BOLD);
        Log.d(TextViewActitvity.class.getName(), String.valueOf(spannable.length()));
        spannable.setSpan(styleSpan, 0, 4, Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
    }
}